//
//  YYJLTabBarController.m
//  YuanyangJinlou
//
//  Created by mac004 on 2016/12/26.
//  Copyright © 2016年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLTabBarController.h"
#import "YYJLCenteController.h"
#import "YYJLCircleController.h"
#import "YYJLHomePageController.h"
#import "YYJLStudyController.h"
#import "YYJLNavController.h"
@interface YYJLTabBarController ()

@end

@implementation YYJLTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // 1.初始化子控制器
    
    YYJLHomePageController *spaceVC = [[YYJLHomePageController alloc]init];
    [self addChildVC:spaceVC title:@"" image:@"ico_shouye_nor"selectedImage:@"ico_shouye_sel"];
    
    
    YYJLStudyController*storyVC = [[YYJLStudyController alloc] init];
    [self addChildVC:storyVC title:@"" image:@"ico_book_nor" selectedImage:@"ico_book_sel"];
    
    
        
    
    YYJLCircleController *forum = [[YYJLCircleController alloc]init];
    [self addChildVC:forum title:@"" image:@"ico_quanzi_nor" selectedImage:@"ico_quanzi_sel"];
    
    
    YYJLCenteController *onlineVC = [[YYJLCenteController alloc]init];
    [self addChildVC:onlineVC title:@"" image:@"ico_wode_nor" selectedImage:@"ico_wode_sel"];
    //默认选择第二个控制器
    self.selectedIndex = 0;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/**
 *  添加子控制器
 */
- (void)addChildVC:(UIViewController *)childVC title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
    
    childVC.title = title;
    
    childVC.tabBarItem.image = [UIImage imageNamed:image];
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    // 设置文字样式
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    textAttrs[NSForegroundColorAttributeName] = [UIColor colorWithRed:141/255.0f green:141/255.0f blue:141/255.0f alpha:1.0f];
    
    NSMutableDictionary *seleTextAttrs = [NSMutableDictionary dictionary];
    seleTextAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    
 //   seleTextAttrs[NSForegroundColorAttributeName] = TINK_BG_COLOR;
    
    [childVC.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    [childVC.tabBarItem setTitleTextAttributes:seleTextAttrs forState:UIControlStateSelected];
    
   YYJLNavController *nav = [[YYJLNavController alloc]initWithRootViewController:childVC];
    
    
    [self addChildViewController:nav];
    
    
    
    
    
}
- (BOOL)shouldAutorotate
{
    return [self.selectedViewController shouldAutorotate];
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    return [self.selectedViewController supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [self.selectedViewController preferredInterfaceOrientationForPresentation];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
